$(function() {
	var $nav_li = $(".header .nav li")
	$nav_li.removeClass('checked');
	$nav_li.each(function() {
		if ($(this).children('a').text().indexOf('政务服务') != -1) {
			$(this).addClass('checked');
		}
	});
	
	
	$(document).on("click", ".left-tab a", function() {
		$(".left-tab a").removeClass("active");
		$(this).addClass("active");
	})
	
	var channelName = getQueryString("name");
	
	if(channelName=='xzxk'){
		$(".left-tab a").removeClass("active");
		 $("#a_245").addClass('active');
	     skip(channelName);
	 	 $("#xzxk_div").removeClass('hidden');
	 	 $("#xzcf_div").addClass('hidden');
	 	 $("#xzqz_div").addClass('hidden');
	}
	
	if(channelName=='xzqz'){
		$(".left-tab a").removeClass("active");
		 $("#a_246").addClass('active');
	     skip(channelName);
	 	 $("#xzqz_div").removeClass('hidden');
	 	 $("#xzcf_div").addClass('hidden');
	 	 $("#xzxk_div").addClass('hidden');
	}

	// 执行一个laydate实例
	laydate.render({
		elem : '#startTime' // 指定元素
	});
	// 执行一个laydate实例
	laydate.render({
		elem : '#endTime' // 指定元素
	});
});
function openIframe(url) {
	$("#xzcf").attr("src", url);
}

function skip(path) {
	var channelId;
	if(path=="xzxk"){
		channelId=245;
	}else if(path=="xzqz"){
		channelId=246;
	}
	var url = "/iframe/"+path+"List.jhtml?channelId="+channelId;
	console.log(url)
	$("#"+path).attr("src", url);
}
function xzxkSubmit() {
	var startTime = "";
	var endTime = "";
	var inputVlue = $("input[name='applyTime']:checked").val();
	switch (inputVlue) {
	case "1":
		startTime = getDate(0);
		endTime = getDate(0);
		break;
	case "2":
		startTime = getMonday("s", 0);
		endTime = getMonday("e", 0);
		break;
	case "3":
		startTime = getMonth("s", 0);
		endTime = getMonth("e", 0);
		break;
	case "4":
		startTime = $("#startTime").val();
		endTime = $("#endTime").val();
		break;
	default:
		break;
	}
	var param = "?channelId=245"
			+ "&referenceNo=" + $("#referenceNo").val() + "&sljg=" + $("#sljg").val()
			+ "&xzStartTime=" + startTime + "&xzEndTime=" + endTime;
	url = "/iframe/xzxkList.jhtml" + param;
	$("#xzxk").attr("src", url);
}
function xzqzSubmit() {
	var startTime = "";
	var endTime = "";
	var inputVlue = $("input[name='qzjdrq']:checked").val();
	switch (inputVlue) {
	case "1":
		startTime = getDate(0);
		endTime = getDate(0);
		break;
	case "2":
		startTime = getMonday("s", 0);
		endTime = getMonday("e", 0);
		break;
	case "3":
		startTime = getMonth("s", 0);
		endTime = getMonth("e", 0);
		break;
	case "4":
		startTime = $("#qzstartTime").val();
		endTime = $("#qzendTime").val();
		break;
	default:
		break;
	}
	
	var param = "?channelId=246"
			+ "&referenceNo=" + $("#qzreferenceNo").val() + "&qzjgmc=" + $("#qzjgmc").val()+"&qzcwmc="+$("#qzcwmc").val()
			+ "&xzStartTime=" + startTime + "&xzEndTime=" + endTime;
	url = "/iframe/xzqzList.jhtml" + param;
	$("#xzqz").attr("src", url);
}
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
}
